package com.haoyu;

public class Duration {

    private int hour;

    private int minute;

    private int second;

    public Duration(){

    }

    public Duration(String minute, String second) {
        this.minute = Integer.parseInt(minute);
        this.second = Integer.parseInt(second);
    }

    public Duration(int minute, int second) {
        this.minute = minute;
        this.second = second;
    }

    public int getHour() {
        return hour;
    }

    public void setHour(int hour) {
        this.hour = hour;
    }

    public int getMinute() {
        return minute;
    }

    public void setMinute(int minute) {
        this.minute = minute;
    }

    public int getSecond() {
        return second;
    }

    public void setSecond(int second) {
        this.second = second;
    }

    public String timeFormat() {
        String formatted = "";
        if (minute >= 60) {
            hour = minute / 60;
            minute = minute % 60;
        }
        if(hour > 0) {
            formatted += hour + ":";
        }

        String minute_s, second_s;
        if(minute < 10 && hour > 0){
            minute_s = "0" + minute;
        } else {
            minute_s = String.valueOf(minute);
        }

        if(second < 10){
            second_s = "0" + second;
        } else {
            second_s = String.valueOf(second);
        }

        formatted += minute_s + ":" + second_s;
        return formatted;
    }

    public boolean isEmpty() {
        return hour == 0 && minute == 0 && second == 0;
    }
}
